package cn.usts.edu.lesson03;

import java.awt.*;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;

public class MyPaint {
    public static void main(String[] args) {
        new Paint01().loadPaint();
    }
}


class Paint01 extends Frame{

    public void loadPaint(){
        setBounds(200,200,800,800);
        setVisible(true);

        // 退出监听
        addWindowListener(new WindowAdapter() {
            @Override
            public void windowClosing(WindowEvent e) {
                System.exit(0);
            }
        });
    }

    @Override
    // 重写paint方法
    public void paint(Graphics g) {
        //super.paint(g);
        g.setColor(Color.red);// 设置颜色red

        g.drawOval(100,200,100,100);  // draw(空心)椭圆
        g.fillOval(250,200,100,100);  // fill(实心)
        g.setColor(Color.orange);
        g.fillRect(400,200,100,100);  // 实心矩形
    }
}